package com.example.demo;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;


@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;


    @Tool(description = "根据用户名获取用户年龄")
    public Integer getAgeByName(@ToolParam(description = "用户名") String name) {
        return userMapper.selectByName(name).getAge();
    }


    @Tool(description = "获取微博热搜")
    public String getWeiboHotSearch() {
        return RestClient.create()
                .get()
                .uri("http://shanhe.kim/api/za/weibo.php")
                .retrieve()
                .body(String.class);
    }
}
